import Vue from 'vue'
import VueRouter from 'vue-router'

// 导入路由组件
import Home from '@/views/Home'
import Login from '@/views/Login'
import Register from '@/views/Register'
import Search from '@/views/Search'
import Test from '@/views/Test'

// 导入对路由方法增强的模块
import './extendMethod'

Vue.use(VueRouter)

// 配置路由规则
const routes = [
  {
    path: '/',
    redirect: '/index'
  },
  {
    path: '/index',
    component: Home
  },
  {
    path: '/login',
    component: Login,
    // meta 路由元信息：让程序员自定义一些属性
    meta: {
      hiddenFooter: true
    }
  },
  {
    path: '/register',
    component: Register,
    meta: {
      hiddenFooter: true
    }
  },
  {
    path: '/search',
    component: Search,
    name: 'search'
  },
  {
    path: '*',
    redirect: '/index'
  },
  {
    path: '/test',
    component: Test
  }
]

const router = new VueRouter({
  routes
})

export default router
